/*
ID: icerupt1
PROG: ratios
LANG: C++11
*/

/* solution
 *
 *
*/
#include <fstream>
#include <iostream>
#include <algorithm>

std::ifstream fin {"ratios.in" };
std::ofstream fout{"ratios.out"};

struct mixtrue { int x, y, z; };

auto& operator>>(std::ifstream& is, mixtrue& a)
{
	is >> a.x >> a.y >> a.z;
	return is;
}

auto operator*(int b, mixtrue a)
{
	a.x *= b; a.y *= b; a.z *= b;
	return a;
}

auto operator+(mixtrue a, mixtrue const & b)
{
	a.x += b.x; a.y += b.y; a.z += b.z;
	return a;
}

mixtrue a, b, c, goal;

bool check(mixtrue a, mixtrue b)
{
	if (b.x == 0 && a.x != 0) return false;
	if (b.y == 0 && a.y != 0) return false;
	if (b.z == 0 && a.z != 0) return false;
	if (a.x == 0 && b.x != 0) return false;
	if (a.y == 0 && b.y != 0) return false;
	if (a.z == 0 && b.z != 0) return false;
	if (a.x % b.x) return false;
	int t = a.x / b.x;
	if (a.y != b.y * t) return false;
	if (a.z != b.z * t) return false;
	return true;
}

int main()
{
	fin >> goal >> a >> b >> c;
	int max = 101, min = 1<<20, multipe = -1;
	mixtrue ans;
	for (auto i = 0; i <= max; i++)
		for (auto j = 0; j <= max; j++)
			for (auto k = 0; k <= max; k++) {
				mixtrue tmp = i*a + j*b + k*c;
				if (check(tmp, goal) && i + j + k < min) {
					min = i + j + k;
					ans.x = i;  ans.y = j;  ans.z = k;
					multipe = tmp.x / goal.x;
				}
			}
	if (multipe == -1) {
		std::cout << "NONE\n";
		fout << "NONE\n";
		return 0;
	}
	std::cout << ans.x << ' ' << ans.y << ' ' << ans.z << ' '
			<< multipe << '\n';
	fout << ans.x << ' ' << ans.y << ' ' << ans.z << ' '
			<< multipe << '\n';
}

